package cn.pxs.service;

import cn.pxs.dao.UserDao;
import cn.pxs.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserDao userDao;


    @Override
    public void add(User u){
        BCryptPasswordEncoder b = new BCryptPasswordEncoder();
        u.setRole("P");
        u.setPassword(b.encode(u.getPassword()));
        userDao.add(u);
    }

    @Override
    public User findByUsername(String name) {
        return userDao.findByUsername(name);
    }
}
